﻿using DevExpress.XtraGrid.Demos.util;
using DevExpress.XtraReports.UI;
using DXApplicationTangche.DTO;
using DXApplicationTangche.report;
using DXApplicationTangche.UC.坚山;
using DXApplicationTangche.UC.抖音出入库.Service;
using DXApplicationTangche.UC.标签打印.Service;
using DXApplicationTangche.UC.订单一览新.辅料.service;
using DXApplicationTangche.UC.金蝶.dto;
using DXApplicationTangche.UC.金蝶.金蝶收款单.Service;
using DXApplicationTangche.UC.金蝶.金蝶退款单.Service;
using DXApplicationTangche.UC.金蝶付款单.Service;
using DXApplicationTangche.UC.门店下单.service;
using DXApplicationTangche.UC.面料审核.Service;
using DXApplicationTangche.UC.面料库存;
using DXApplicationTangche.UC.面料库存.入库.service;
using DXApplicationTangche.UC.面料库存.库存记录.service;
using DXApplicationTangche.Utils;
using Kingdee.BOS.WebApi.Client;
using mendian;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Printing;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using static DXApplicationTangche.UC.金蝶.dto.BomDTO;
using static DXApplicationTangche.UC.金蝶.dto.MaterialDTO;
using static DXApplicationTangche.UC.金蝶.dto.MaterialResultDTO;
using static DXApplicationTangche.UC.金蝶.dto.PurchaseOrderDTO;
using static DXApplicationTangche.UC.金蝶.dto.ResultDTO;
using static DXApplicationTangche.UC.金蝶.dto.StockOutDTO;
using static DXApplicationTangche.UC.金蝶.dto.SupplyDTO;

namespace DXApplicationTangche.UC.金蝶
{
    public partial class Form1 : DevExpress.XtraEditors.XtraForm
    {
        public K3CloudApiClient client = new K3CloudApiClient();
        private List<MaterialImportDTO> materialImportDTOs = new List<MaterialImportDTO>();
        public Form1()
        {
            InitializeComponent();
            InitprinterComboBox();
        }

        private void simpleButton1_Click(object sender, EventArgs e)
        {
            // 使用webapi引用组件Kingdee.BOS.WebApi.Client.dll
            K3CloudApiClient client = new K3CloudApiClient("http://192.168.3.251/k3cloud/");
            var loginResult = client.ValidateLogin("6128407938e2f2", "Administrator", "Sshirt@1234", 2052);
            var resultType = JObject.Parse(loginResult)["LoginResultType"].Value<int>();
            //登录结果类型等于1，代表登录成功
            if (resultType == 1)
            {
                String result = client.Save("BD_MATERIAL", "{\"NeedUpDateFields\":[],\"NeedReturnFields\":[],\"IsDeleteEntry\":\"true\",\"SubSystemId\":\"\",\"IsVerifyBaseDataField\":\"false\",\"IsEntryBatchFill\":\"true\",\"ValidateFlag\":\"true\",\"NumberSearch\":\"true\",\"IsAutoAdjustField\":\"false\",\"InterationFlags\":\"\",\"IgnoreInterationFlag\":\"\",\"Model\":{\"FMATERIALID\":0,\"FNumber\":\"\",\"FName\":\"\",\"FSpecification\":\"\",\"FMnemonicCode\":\"\",\"FOldNumber\":\"\",\"FDescription\":\"\",\"FMaterialGroup\":{\"FNumber\":\"\"},\"FDSMatchByLot\":\"false\",\"FImgStorageType\":\"\",\"FIsSalseByNet\":\"false\",\"FForbidReson\":\"\",\"FExtVar\":\"\",\"FSubHeadEntity\":{\"FEntryId\":0,\"FIsControlSal\":\"false\",\"FLowerPercent\":0,\"FUpPercent\":0,\"FCalculateBase\":\"\",\"FMaxSalPrice_CMK\":0,\"FMinSalPrice_CMK\":0,\"FIsAutoRemove\":\"false\",\"FIsMailVirtual\":\"false\",\"FIsFreeSend\":\"\",\"FPriceType\":\"\",\"FLogisticsCount\":0,\"FRequestMinPackQty\":0,\"FMinRequestQty\":0,\"FRetailUnitID\":{\"FNUMBER\":\"\"},\"FIsPrinttAg\":\"false\",\"FIsAccessory\":\"false\"},\"SubHeadEntity\":{\"FEntryId\":0,\"FBARCODE\":\"\",\"FErpClsID\":\"\",\"FFeatureItem\":\"\",\"FCONFIGTYPE\":\"\",\"FCategoryID\":{\"FNumber\":\"\"},\"FTaxType\":{\"FNumber\":\"\"},\"FTaxRateId\":{\"FNUMBER\":\"\"},\"FBaseUnitId\":{\"FNumber\":\"\"},\"FIsPurchase\":\"false\",\"FIsInventory\":\"false\",\"FIsSubContract\":\"false\",\"FIsSale\":\"false\",\"FIsProduce\":\"false\",\"FIsAsset\":\"false\",\"FGROSSWEIGHT\":0,\"FNETWEIGHT\":0,\"FWEIGHTUNITID\":{\"FNUMBER\":\"\"},\"FLENGTH\":0,\"FWIDTH\":0,\"FHEIGHT\":0,\"FVOLUME\":0,\"FVOLUMEUNITID\":{\"FNUMBER\":\"\"},\"FSuite\":\"\",\"FCostPriceRate\":0},\"SubHeadEntity1\":{\"FEntryId\":0,\"FStoreUnitID\":{\"FNumber\":\"\"},\"FAuxUnitID\":{\"FNumber\":\"\"},\"FUnitConvertDir\":\"\",\"FStockId\":{\"FNumber\":\"\"},\"FStockPlaceId\":{},\"FIsLockStock\":\"false\",\"FIsCycleCounting\":\"false\",\"FCountCycle\":\"\",\"FCountDay\":0,\"FIsMustCounting\":\"false\",\"FIsBatchManage\":\"false\",\"FBatchRuleID\":{\"FNumber\":\"\"},\"FIsKFPeriod\":\"false\",\"FIsExpParToFlot\":\"false\",\"FExpUnit\":\"\",\"FExpPeriod\":0,\"FOnlineLife\":0,\"FRefCost\":0,\"FCurrencyId\":{\"FNumber\":\"\"},\"FIsEnableMinStock\":\"false\",\"FIsEnableMaxStock\":\"false\",\"FIsEnableSafeStock\":\"false\",\"FIsEnableReOrder\":\"false\",\"FMinStock\":0,\"FSafeStock\":0,\"FReOrderGood\":0,\"FEconReOrderQty\":0,\"FMaxStock\":0,\"FIsSNManage\":\"false\",\"FIsSNPRDTracy\":\"false\",\"FSNCodeRule\":{\"FNumber\":\"\"},\"FSNUnit\":{\"FNumber\":\"\"},\"FSNManageType\":\"\",\"FSNGenerateTime\":\"\",\"FBoxStandardQty\":0},\"SubHeadEntity2\":{\"FEntryId\":0,\"FSaleUnitId\":{\"FNumber\":\"\"},\"FSalePriceUnitId\":{\"FNumber\":\"\"},\"FOrderQty\":0,\"FMinQty\":0,\"FMaxQty\":0,\"FOutStockLmtH\":0,\"FOutStockLmtL\":0,\"FAgentSalReduceRate\":0,\"FIsATPCheck\":\"false\",\"FIsReturnPart\":\"false\",\"FIsInvoice\":\"false\",\"FIsReturn\":\"false\",\"FAllowPublish\":\"false\",\"FISAFTERSALE\":\"false\",\"FISPRODUCTFILES\":\"false\",\"FISWARRANTED\":\"false\",\"FWARRANTY\":0,\"FWARRANTYUNITID\":\"\",\"FOutLmtUnit\":\"\",\"FTaxCategoryCodeId\":{\"FNUMBER\":\"\"},\"FSalGroup\":{\"FNumber\":\"\"},\"FIsTaxEnjoy\":\"false\",\"FTaxDiscountsType\":\"\",\"FUnValidateExpQty\":\"false\"},\"SubHeadEntity3\":{\"FEntryId\":0,\"FBaseMinSplitQty\":0,\"FPurchaseUnitId\":{\"FNumber\":\"\"},\"FPurchasePriceUnitId\":{\"FNumber\":\"\"},\"FPurchaseGroupId\":{\"FNumber\":\"\"},\"FPurchaserId\":{\"FNumber\":\"\"},\"FDefaultVendor\":{\"FNumber\":\"\"},\"FChargeID\":{\"FNumber\":\"\"},\"FIsQuota\":\"false\",\"FQuotaType\":\"\",\"FMinSplitQty\":0,\"FIsVmiBusiness\":\"false\",\"FEnableSL\":\"false\",\"FIsPR\":\"false\",\"FIsReturnMaterial\":\"false\",\"FIsSourceControl\":\"false\",\"FReceiveMaxScale\":0,\"FReceiveMinScale\":0,\"FReceiveAdvanceDays\":0,\"FReceiveDelayDays\":0,\"FPOBillTypeId\":{\"FNUMBER\":\"\"},\"FAgentPurPlusRate\":0,\"FDefBarCodeRuleId\":{\"FNUMBER\":\"\"},\"FPrintCount\":0,\"FMinPackCount\":0},\"SubHeadEntity4\":{\"FEntryId\":0,\"FPlanMode\":\"\",\"FBaseVarLeadTimeLotSize\":0,\"FPlanningStrategy\":\"\",\"FMfgPolicyId\":{\"FNumber\":\"\"},\"FOrderPolicy\":\"\",\"FPlanWorkshop\":{\"FNumber\":\"\"},\"FFixLeadTime\":0,\"FFixLeadTimeType\":\"\",\"FVarLeadTime\":0,\"FVarLeadTimeType\":\"\",\"FCheckLeadTime\":0,\"FCheckLeadTimeType\":\"\",\"FOrderIntervalTimeType\":\"\",\"FOrderIntervalTime\":0,\"FMaxPOQty\":0,\"FMinPOQty\":0,\"FIncreaseQty\":0,\"FEOQ\":0,\"FVarLeadTimeLotSize\":0,\"FPlanIntervalsDays\":0,\"FPlanBatchSplitQty\":0,\"FRequestTimeZone\":0,\"FPlanTimeZone\":0,\"FPlanGroupId\":{\"FNumber\":\"\"},\"FATOSchemeId\":{\"FNUMBER\":\"\"},\"FPlanerID\":{\"FNumber\":\"\"},\"FIsMrpComBill\":\"false\",\"FCanLeadDays\":0,\"FIsMrpComReq\":\"false\",\"FLeadExtendDay\":0,\"FReserveType\":\"\",\"FPlanSafeStockQty\":0,\"FAllowPartAhead\":\"false\",\"FCanDelayDays\":0,\"FDelayExtendDay\":0,\"FAllowPartDelay\":\"false\",\"FPlanOffsetTimeType\":\"\",\"FPlanOffsetTime\":0,\"FSupplySourceId\":{\"FNumber\":\"\"},\"FTimeFactorId\":{\"FNumber\":\"\"},\"FQtyFactorId\":{\"FNumber\":\"\"},\"FProductLine\":{\"FNUMBER\":\"\"},\"FWriteOffQty\":0,\"FPlanIdent\":{\"FNumber\":\"\"},\"FProScheTrackId\":{\"FNumber\":\"\"},\"FDailyOutQty\":0},\"SubHeadEntity5\":{\"FEntryId\":0,\"FWorkShopId\":{\"FNumber\":\"\"},\"FProduceUnitId\":{\"FNumber\":\"\"},\"FFinishReceiptOverRate\":0,\"FFinishReceiptShortRate\":0,\"FProduceBillType\":{\"FNUMBER\":\"\"},\"FOrgTrustBillType\":{\"FNUMBER\":\"\"},\"FIsSNCarryToParent\":\"false\",\"FIsProductLine\":\"false\",\"FBOMUnitId\":{\"FNumber\":\"\"},\"FLOSSPERCENT\":0,\"FConsumVolatility\":0,\"FIsMainPrd\":\"false\",\"FIsCoby\":\"false\",\"FIsECN\":\"false\",\"FIssueType\":\"\",\"FBKFLTime\":\"\",\"FPickStockId\":{\"FNumber\":\"\"},\"FPickBinId\":{},\"FOverControlMode\":\"\",\"FMinIssueQty\":0,\"FISMinIssueQty\":\"false\",\"FIsKitting\":\"false\",\"FIsCompleteSet\":\"false\",\"FDefaultRouting\":{\"FNumber\":\"\"},\"FStdLaborPrePareTime\":0,\"FStdLaborProcessTime\":0,\"FStdMachinePrepareTime\":0,\"FStdMachineProcessTime\":0,\"FMinIssueUnitId\":{\"FNUMBER\":\"\"},\"FMdlId\":{\"FNUMBER\":\"\"},\"FMdlMaterialId\":{\"FNUMBER\":\"\"},\"FStandHourUnitId\":\"\",\"FBackFlushType\":\"\",\"FFIXLOSS\":0},\"SubHeadEntity7\":{\"FEntryId\":0,\"FSubconUnitId\":{\"FNumber\":\"\"},\"FSubconPriceUnitId\":{\"FNumber\":\"\"},\"FSubBillType\":{\"FNUMBER\":\"\"}},\"SubHeadEntity6\":{\"FEntryId\":0,\"FCheckIncoming\":\"false\",\"FCheckProduct\":\"false\",\"FCheckStock\":\"false\",\"FCheckReturn\":\"false\",\"FCheckDelivery\":\"false\",\"FEnableCyclistQCSTK\":\"false\",\"FStockCycle\":0,\"FEnableCyclistQCSTKEW\":\"false\",\"FEWLeadDay\":0,\"FIncSampSchemeId\":{\"FNUMBER\":\"\"},\"FIncQcSchemeId\":{\"FNUMBER\":\"\"},\"FInspectGroupId\":{\"FNUMBER\":\"\"},\"FInspectorId\":{\"FNUMBER\":\"\"},\"FCheckEntrusted\":\"false\",\"FCheckOther\":\"false\",\"FIsFirstInspect\":\"false\",\"FCheckReturnMtrl\":\"false\"},\"FBarCodeEntity_CMK\":[{\"FEntryID\":0,\"FCodeType_CMK\":\"\",\"FUnitId_CMK\":{\"FNUMBER\":\"\"}}],\"FSpecialAttributeEntity\":[{\"FEntryID\":0}],\"FEntityAuxPty\":[{\"FEntryID\":0,\"FAuxPropertyId\":{\"FNumber\":\"\"},\"FIsEnable1\":\"false\",\"FIsComControl\":\"false\",\"FIsAffectPrice1\":\"false\",\"FIsAffectPlan1\":\"false\",\"FIsAffectCost1\":\"false\",\"FIsMustInput\":\"false\",\"FValueType\":\"\"}],\"FEntityInvPty\":[{\"FEntryID\":0,\"FInvPtyId\":{\"FNumber\":\"\"},\"FIsEnable\":\"false\",\"FIsAffectPrice\":\"false\",\"FIsAffectPlan\":\"false\",\"FIsAffectCost\":\"false\"}]}}");
            }

        }

        private void simpleButton3_Click(object sender, EventArgs e)
        {
            // 使用webapi引用组件Kingdee.BOS.WebApi.Client.dll
            K3CloudApiClient client = new K3CloudApiClient("http://192.168.3.251/k3cloud/");
            var loginResult = client.ValidateLogin("6128407938e2f2", "Administrator", "Sshirt@1234", 2052);
            var resultType = JObject.Parse(loginResult)["LoginResultType"].Value<int>();
            //登录结果类型等于1，代表登录成功
            if (resultType == 1)
            {
                //新建
                String result = client.Save("BD_Supplier", FunctionHelper.JsonSerialization(new FBillHead("测试123")));
                //提交 取新建返回的result反序列化
                ResultRoot resultRoot = FunctionHelper.JsonDeserialization<ResultRoot>(result);
                String Submitresult = client.Submit("BD_Supplier", FunctionHelper.JsonSerialization(new SupplierSubmitDTO(resultRoot.Result.Number, resultRoot.Result.Id.ToString())));
                //审核
                String SupplierVerifyresult = client.Audit("BD_Supplier", FunctionHelper.JsonSerialization(new SupplierVerifyDTO(resultRoot.Result.Number, resultRoot.Result.Id.ToString())));
            }
        }

        private void simpleButton4_Click(object sender, EventArgs e)
        {
            // 使用webapi引用组件Kingdee.BOS.WebApi.Client.dll
            K3CloudApiClient client = new K3CloudApiClient("http://192.168.3.251/k3cloud/");
            var loginResult = client.ValidateLogin("6128407938e2f2", "Administrator", "Sshirt@1234", 2052);
            var resultType = JObject.Parse(loginResult)["LoginResultType"].Value<int>();
            //登录结果类型等于1，代表登录成功
            if (resultType == 1)
            {
                String result = client.View("BD_Supplier", "{\"Number\":\"VEN00001\",\"Id\":\"100311\"}");
            }
        }

        private void simpleButton5_Click(object sender, EventArgs e)
        {
            K3CloudApiClient client = new K3CloudApiClient("http://192.168.3.251/k3cloud/");
            var loginResult = client.ValidateLogin("6128407938e2f2", "Administrator", "Sshirt@1234", 2052);
            var resultType = JObject.Parse(loginResult)["LoginResultType"].Value<int>();
            //登录结果类型等于1，代表登录成功
            if (resultType == 1)
            {
                String Submitresult = client.Submit("BD_Supplier", FunctionHelper.JsonSerialization(new SupplierSubmitDTO("VEN00004", "100515")));
                String result = client.Audit("BD_Supplier", FunctionHelper.JsonSerialization(new SupplierVerifyDTO("VEN00004", "100515")));
            }
        }
        private void simpleButton2_Click(object sender, EventArgs e)
        {
            // 使用webapi引用组件Kingdee.BOS.WebApi.Client.dll
            K3CloudApiClient client = new K3CloudApiClient("http://192.168.3.251/k3cloud/");
            var loginResult = client.ValidateLogin("6128407938e2f2", "Administrator", "Sshirt@1234", 2052);
            var resultType = JObject.Parse(loginResult)["LoginResultType"].Value<int>();
            //登录结果类型等于1，代表登录成功
            if (resultType == 1)
            {
                //自制
                String result = client.View("BD_MATERIAL", "{\"Number\":\"CH4426\",\"Id\":\"100561\"}");
                //外购
                //String result = client.View("BD_MATERIAL", "{\"Number\":\"CH4415\",\"Id\":\"100535\"}");
                //自制
                //String result = client.View("BD_MATERIAL", "{\"Number\":\"CH4449\",\"Id\":\"100528\"}");
                //String result = client.View("BD_MATERIAL", "{\"Number\":\"4412\",\"Id\":\"100532\"}");
                //存货类别  产成品
                //String result = client.View("BD_MATERIAL", "{\"Number\":\"CH4446\",\"Id\":\"100525\"}");
            }
        }
        private void simpleButton6_Click(object sender, EventArgs e)
        {
            // 使用webapi引用组件Kingdee.BOS.WebApi.Client.dll
            K3CloudApiClient client = new K3CloudApiClient("http://192.168.3.251/k3cloud/");
            var loginResult = client.ValidateLogin("6128407938e2f2", "Administrator", "Sshirt@1234", 2052);
            var resultType = JObject.Parse(loginResult)["LoginResultType"].Value<int>();
            //登录结果类型等于1，代表登录成功
            if (resultType == 1)
            {
                //外购
                //String ErpClsIDresult = client.Save("BD_MATERIAL", FunctionHelper.JsonSerialization(new Root("YJ-B18外购面料测试-02", "面料")));
                //自制，产成品
                String result = client.Save("BD_MATERIAL", FunctionHelper.JsonSerialization(new Root("19FJ-测试款号","YJ-B20测试面料")));
                //面料
                //String result = client.Save("BD_MATERIAL", FunctionHelper.JsonSerialization(new Root("17FJ-", "测试面料", "VEN00004", 0)));
                //辅料
                //String result = client.Save("BD_MATERIAL", FunctionHelper.JsonSerialization(new Root("JM-21", "测试辅料", "扣", "1", "Pcs", "FYXM01_SYS", "VEN00004", "CK004")));
                KingDeeAddResultRoot materialResultRoot = FunctionHelper.JsonDeserialization<KingDeeAddResultRoot>(result);
                String Submitresult = client.Submit("BD_MATERIAL", FunctionHelper.JsonSerialization(new dto.MaterialSubmitDTO(materialResultRoot.Result.Number, materialResultRoot.Result.Id.ToString())));
                String SupplierVerifyresult = client.Audit("BD_MATERIAL", FunctionHelper.JsonSerialization(new dto.MaterialVerifyDTO(materialResultRoot.Result.Number, materialResultRoot.Result.Id.ToString())));
            }
        }

        private void simpleButton7_Click(object sender, EventArgs e)
        {
            // 使用webapi引用组件Kingdee.BOS.WebApi.Client.dll
            K3CloudApiClient client = new K3CloudApiClient("http://192.168.3.251/k3cloud/");
            var loginResult = client.ValidateLogin("6128407938e2f2", "Administrator", "Sshirt@1234", 2052);
            var resultType = JObject.Parse(loginResult)["LoginResultType"].Value<int>();
            List<ChildDTO> childDTOs = new List<ChildDTO>();
            childDTOs.Add(new ChildDTO("CH1002", 5));
            childDTOs.Add(new ChildDTO("CH1001", 10));
            //登录结果类型等于1，代表登录成功
            if (resultType == 1)
            {
                //MBOM
                //String result = client.Save("ENG_BOM", FunctionHelper.JsonSerialization(new BomRoot("20FJ11-7", "CH2279",1, "CH1001", 5)));
                //EBOM
                String result = client.Save("ENG_BOM", FunctionHelper.JsonSerialization(new BomRoot("19FP11", "CH2280", 0, childDTOs)));
                KingDeeAddResultRoot materialResultRoot = FunctionHelper.JsonDeserialization<KingDeeAddResultRoot>(result);
                String Submitresult = client.Submit("ENG_BOM", FunctionHelper.JsonSerialization(new dto.MaterialSubmitDTO(materialResultRoot.Result.Number, materialResultRoot.Result.Id.ToString())));
                String SupplierVerifyresult = client.Audit("ENG_BOM", FunctionHelper.JsonSerialization(new dto.MaterialVerifyDTO(materialResultRoot.Result.Number, materialResultRoot.Result.Id.ToString())));
            }
        }

        private void simpleButton8_Click(object sender, EventArgs e)
        {
            // 使用webapi引用组件Kingdee.BOS.WebApi.Client.dll
            K3CloudApiClient client = new K3CloudApiClient("http://192.168.3.251/k3cloud/");
            var loginResult = client.ValidateLogin("6128407938e2f2", "Administrator", "Sshirt@1234", 2052);
            var resultType = JObject.Parse(loginResult)["LoginResultType"].Value<int>();
            //登录结果类型等于1，代表登录成功
            if (resultType == 1)
            {
                //String result = client.View("ENG_BOM", "{\"Number\":\"CH2279_V1.0\",\"Id\":\"103010\"}");
                //String result = client.View("ENG_BOM", "{\"Number\":\"CH2280_V1.1\",\"Id\":\"103012\"}");
                //String result = client.View("ENG_BOM", "{\"Number\":\"CH2280_V1.4\",\"Id\":\"103048\"}");
                String result = client.View("ENG_BOM", "{\"Number\":\"CH2986_V1.0\",\"Id\":\"103827\"}");
            }
        }

        private void simpleButton9_Click(object sender, EventArgs e)
        {
            this.金蝶物料保存("002001");
            //this.金蝶辅料保存("kou.20.000192");
        }

        private void 金蝶物料保存(String materialNo)
        {
            //判断面料号是否存在
            //存在面料号
            if (!入库Service.fabricExisted(materialNo))
            {
                //根据面料号查询其他信息
                DTO面料库存 DTO面料库存 = 面料记录Service.getMaterialInfoByMaterialNo(materialNo);
                if (!String.IsNullOrEmpty(DTO面料库存.id))
                {
                    //金蝶保存
                    //入库Service.金蝶物料保存("VEN00004", DTO面料库存);
                }
            }
        }

        private void 金蝶辅料保存(String accessoryCode)
        {
            DTO辅料一览 DTO辅料一览 = 辅料Service.getAccessoryByAccessoryCode(accessoryCode);
            FunctionHelper.JsonSerialization(DTO辅料一览);
            //辅料Service.金蝶辅料保存("VEN00004", DTO辅料一览);
        }

        private int 金蝶登录判断()
        {
            // 使用webapi引用组件Kingdee.BOS.WebApi.Client.dll
            this.client = new K3CloudApiClient("http://192.168.3.251/k3cloud/");
            var loginResult = client.ValidateLogin("6128407938e2f2", "Administrator", "Sshirt@1234", 2052);
            var resultType = JObject.Parse(loginResult)["LoginResultType"].Value<int>();
            return resultType;
        }

        private void simpleButton10_Click(object sender, EventArgs e)
        {
            // 使用webapi引用组件Kingdee.BOS.WebApi.Client.dll
            K3CloudApiClient client = new K3CloudApiClient("http://192.168.3.251/k3cloud/");
            var loginResult = client.ValidateLogin("6128407938e2f2", "Administrator", "Sshirt@1234", 2052);
            var resultType = JObject.Parse(loginResult)["LoginResultType"].Value<int>();
            List<PurchaseChildDTO> purchaseChildDTOs = new List<PurchaseChildDTO>();
            purchaseChildDTOs.Add(new PurchaseChildDTO("CH4295", 100.01));
            purchaseChildDTOs.Add(new PurchaseChildDTO("CH4296", 200.01));
            //登录结果类型等于1，代表登录成功
            if (resultType == 1)
            {
                //PurchaseOrderRoot p = new PurchaseOrderRoot("VEN00004", purchaseChildDTOs);
                //String result = client.Save("PUR_PurchaseOrder", FunctionHelper.JsonSerialization(p));
                //String result = client.Save("PUR_PurchaseOrder", FunctionHelper.JsonSerialization(new PurchaseOrderRoot("VEN00004", purchaseChildDTOs)));
                //MaterialResultRoot materialResultRoot = FunctionHelper.JsonDeserialization<MaterialResultRoot>(result);
                //String Fnumber = materialResultRoot.Result.Number;
                //String Fid = materialResultRoot.Result.Id.ToString();
                //String Submitresult = client.Submit("PUR_PurchaseOrder", FunctionHelper.JsonSerialization(new MaterialSubmitDTO(materialResultRoot.Result.Number, materialResultRoot.Result.Id.ToString())));
                //String SupplierVerifyresult = client.Audit("PUR_PurchaseOrder", FunctionHelper.JsonSerialization(new MaterialVerifyDTO(materialResultRoot.Result.Number, materialResultRoot.Result.Id.ToString())));
            }
        }

        private void simpleButton11_Click(object sender, EventArgs e)
        {
            // 使用webapi引用组件Kingdee.BOS.WebApi.Client.dll
            K3CloudApiClient client = new K3CloudApiClient("http://192.168.3.251/k3cloud/");
            var loginResult = client.ValidateLogin("6128407938e2f2", "Administrator", "Sshirt@1234", 2052);
            var resultType = JObject.Parse(loginResult)["LoginResultType"].Value<int>();
            //登录结果类型等于1，代表登录成功
            if (resultType == 1)
            {
                String result = client.View("PUR_PurchaseOrder", "{\"Number\":\"CGDD000041\",\"Id\":\"100041\"}");
            }
        }

        private void simpleButton12_Click(object sender, EventArgs e)
        {

        }

        private void simpleButton13_Click(object sender, EventArgs e)
        {
            // 使用webapi引用组件Kingdee.BOS.WebApi.Client.dll
            K3CloudApiClient client = new K3CloudApiClient("http://192.168.3.251/k3cloud/");
            var loginResult = client.ValidateLogin("6128407938e2f2", "Administrator", "Sshirt@1234", 2052);
            var resultType = JObject.Parse(loginResult)["LoginResultType"].Value<int>();
            //登录结果类型等于1，代表登录成功
            if (resultType == 1)
            {
                String result = client.View("STK_InvInit", "{\"Number\":\"CSKC003\",\"Id\":\"100003\"}");
            }
        }

        private void simpleButton15_Click(object sender, EventArgs e)
        {
            // 使用webapi引用组件Kingdee.BOS.WebApi.Client.dll
            K3CloudApiClient client = new K3CloudApiClient("http://192.168.3.251/k3cloud/");
            var loginResult = client.ValidateLogin("6128407938e2f2", "Administrator", "Sshirt@1234", 2052);
            var resultType = JObject.Parse(loginResult)["LoginResultType"].Value<int>();
            //登录结果类型等于1，代表登录成功
            if (resultType == 1)
            {
                String result = client.View("STK_MisDelivery", "{\"Number\":\"QTCK000028\",\"Id\":\"100028\"}");
            }
        }

        private void simpleButton14_Click(object sender, EventArgs e)
        {
            // 使用webapi引用组件Kingdee.BOS.WebApi.Client.dll
            K3CloudApiClient client = new K3CloudApiClient("http://192.168.3.251/k3cloud/");
            var loginResult = client.ValidateLogin("6128407938e2f2", "Administrator", "Sshirt@1234", 2052);
            var resultType = JObject.Parse(loginResult)["LoginResultType"].Value<int>();
            List<StockOutChildDTO> stockOutChildDTOs = new List<StockOutChildDTO>();
            stockOutChildDTOs.Add(new StockOutChildDTO("CH1046", 2));
            //登录结果类型等于1，代表登录成功
            if (resultType == 1)
            {
                //String result = client.Save("STK_MisDelivery", FunctionHelper.JsonSerialization(new StockOutRoot(stockOutChildDTOs)));
                //MaterialResultRoot materialResultRoot = FunctionHelper.JsonDeserialization<MaterialResultRoot>(result);
                //String Submitresult = client.Submit("STK_MisDelivery", FunctionHelper.JsonSerialization(new MaterialSubmitDTO(materialResultRoot.Result.Number, materialResultRoot.Result.Id.ToString())));
                //String SupplierVerifyresult = client.Audit("STK_MisDelivery", FunctionHelper.JsonSerialization(new MaterialVerifyDTO(materialResultRoot.Result.Number, materialResultRoot.Result.Id.ToString())));
            }
        }

        private void simpleButton16_Click(object sender, EventArgs e)
        {
            // 使用webapi引用组件Kingdee.BOS.WebApi.Client.dll
            K3CloudApiClient client = new K3CloudApiClient("http://192.168.3.251/k3cloud/");
            var loginResult = client.ValidateLogin("6128407938e2f2", "Administrator", "Sshirt@1234", 2052);
            var resultType = JObject.Parse(loginResult)["LoginResultType"].Value<int>();
            //登录结果类型等于1，代表登录成功
            if (resultType == 1)
            {
                String result = client.Delete("STK_MisDelivery", "{\"Number\":\"QTCK000028\",\"Id\":\"100028\",\"NetworkCtrl\":\"\"}");
            }
        }

        private void simpleButton17_Click(object sender, EventArgs e)
        {
            Stopwatch stopWatch = new Stopwatch();
            stopWatch.Start();
            ExcelAndPath excelAndPath = ExcelUtil.getExcelDataAndPath("");
            if (excelAndPath == null)
            {
                return;
            }
            DataSet result = excelAndPath.DataSet;
            stopWatch.Stop();
            System.Diagnostics.Debug.WriteLine("导成Dataset用时" + stopWatch.ElapsedMilliseconds + "ms");
            stopWatch.Start();
            if (result == null)
            {
                return;
            }
            DataTable dataTable = result.Tables[0];
            //读取excel数据
            String materialNo;
            String meterialDesc;
            String fSupplierNumber;
            int group;
            for (int i = 1; i < 100; i++)
            {
                try
                {
                    if (String.IsNullOrEmpty(dataTable.Rows[i]["Column0"].ToString()))
                    {
                        break;
                    }
                }
                catch (Exception)
                {
                    break;
                }
                materialNo = dataTable.Rows[i]["Column0"].ToString();
                meterialDesc = dataTable.Rows[i]["Column1"].ToString();
                fSupplierNumber = dataTable.Rows[i]["Column2"].ToString();
                group = 0;
                this.materialImportDTOs.Add(new MaterialImportDTO(materialNo, meterialDesc, fSupplierNumber, group));
            }
            
            stopWatch.Stop();
            System.Diagnostics.Debug.WriteLine("导成List用时" + stopWatch.ElapsedMilliseconds + "ms");
            stopWatch.Start();
            this.gridControl面料导入.DataSource = materialImportDTOs;
            stopWatch.Stop();
            System.Diagnostics.Debug.WriteLine("Post用时" + stopWatch.ElapsedMilliseconds + "ms");
        }

        private void simpleButton18_Click(object sender, EventArgs e)
        {
            // 使用webapi引用组件Kingdee.BOS.WebApi.Client.dll
            K3CloudApiClient client = new K3CloudApiClient("http://192.168.3.251/k3cloud/");
            var loginResult = client.ValidateLogin("6128407938e2f2", "Administrator", "Sshirt@1234", 2052);
            var resultType = JObject.Parse(loginResult)["LoginResultType"].Value<int>();
            //登录结果类型等于1，代表登录成功
            if (resultType == 1)
            {
                foreach(MaterialImportDTO materialImportDTO in this.materialImportDTOs)
                {
                    //面料
                    String result = client.Save("BD_MATERIAL", FunctionHelper.JsonSerialization(new Root(materialImportDTO.materialNo, materialImportDTO.meterialDesc, materialImportDTO.fSupplierNumber, materialImportDTO.group)));
                    KingDeeAddResultRoot materialResultRoot = FunctionHelper.JsonDeserialization<KingDeeAddResultRoot>(result);
                    String Submitresult = client.Submit("BD_MATERIAL", FunctionHelper.JsonSerialization(new dto.MaterialSubmitDTO(materialResultRoot.Result.Number, materialResultRoot.Result.Id.ToString())));
                    String SupplierVerifyresult = client.Audit("BD_MATERIAL", FunctionHelper.JsonSerialization(new dto.MaterialVerifyDTO(materialResultRoot.Result.Number, materialResultRoot.Result.Id.ToString())));
                }
            }
        }

        private void simpleButton19_Click(object sender, EventArgs e)
        {
            XtraReport受托加工出库单 report = new XtraReport受托加工出库单();
            //report.DataSource = this.saleOrderReportDTO.saleOrderReportDetailDTOS;
            ReportPrintTool tool = new ReportPrintTool(report);
            tool.ShowPreview();
        }

        private void simpleButton21_Click(object sender, EventArgs e)
        {
            new Form坚山产成品交付().ShowDialog();
        }

        private void simpleButton22_Click(object sender, EventArgs e)
        {
            面料审核.Service.MaterialRequirementQueryDTO materialRequirementQueryDTO = 面料审核Service.getMaterialRequirementQueryById("3ab9b79a41e84549a39a68e37c7adaa5");
            XtraReport面料领用出库单 report = new XtraReport面料领用出库单(materialRequirementQueryDTO);
            ReportPrintTool tool = new ReportPrintTool(report);
            tool.ShowPreview();
        }

        private void simpleButton23_Click(object sender, EventArgs e)
        {
            面料审核.Service.MaterialRequirementQueryDTO materialRequirementQueryDTO = 面料审核Service.getMaterialRequirementQueryById("3ab9b79a41e84549a39a68e37c7adaa5");
            XtraReport生产计划单带地址 report = new XtraReport生产计划单带地址(materialRequirementQueryDTO);
            ReportPrintTool tool = new ReportPrintTool(report);
            tool.ShowPreview();
        }

        private void simpleButton24_Click(object sender, EventArgs e)
        {
            List<OrderDetailDTO> orderDetails = new List<OrderDetailDTO>();
            orderDetails.Add(new OrderDetailDTO("SS.SSWX-20211116-000001","测试用户116","1MS衬衫","JM-01","L","1","2021-11-16","春衫定制","1101"));
            orderDetails.Add(new OrderDetailDTO("KA-20211116-000001", "Test01", "1MS衬衫", "JM-5786-02", "M", "1", "2021-11-16", "上海坚山","1202"));
            XtraReport受托加工出库单 report = new XtraReport受托加工出库单(orderDetails);
            ReportPrintTool tool = new ReportPrintTool(report);
            tool.ShowPreview();
        }

        private void simpleButton26_Click(object sender, EventArgs e)
        {
            //明细
            List<OrderDetailDTO> orderDetails = new List<OrderDetailDTO>();
            orderDetails.Add(new OrderDetailDTO("SS.SSWX-20211116-000001", "测试用户116", "1MS衬衫", "JM-01", "L", "1", "2021-11-16", "春衫定制","1101"));
            orderDetails.Add(new OrderDetailDTO("KA-20211116-000001", "Test01", "1MS衬衫", "JM-5786-02", "M", "1", "2021-11-16", "上海坚山","1202"));
            XtraReport受托加工出库单 report明细 = new XtraReport受托加工出库单(orderDetails);
            //抬头
            //XtraReport生产计划单 report = new XtraReport生产计划单(面料审核Service.getMaterialRequirementQueryById("3ab9b79a41e84549a39a68e37c7adaa5"));
            //ReportPrintTool tool = new ReportPrintTool(report);
            //tool.ShowPreview();
        }

        private void simpleButton27_Click(object sender, EventArgs e)
        {
            String filename = "DOUYIN_code93.btw";
            String fileAllname = "D:\\ATEST\\fragment_smart\\DXApplicationTangche\\DXApplicationTangche\\bin\\Debug\\tag\\DOUYIN_code93.btw";

            bool 是否存在 = FileUtil.FileExist(@"tag\" + filename);
            String xx = FileUtil.GetDirectoryName(@"tag\" + fileAllname);
            String xxx = FileUtil.GetPathRoot(@"tag\" + fileAllname);
            String 绝对路径 = FileUtil.getAbsolutePath(@"tag\" + filename);
            String 文件名 = FileUtil.getFileName(filename);
            String 后缀名 = FileUtil.getExtensionName(filename);
        }
        private void InitprinterComboBox()
        {
            List<String> list = LocalPrinter.GetLocalPrinters(); //获得系统中的打印机列表
            foreach (String s in list)
            {
                printerComboBox.Items.Add(s); //将打印机名称添加到下拉框中
            }
        }

        private void simpleButton28_Click(object sender, EventArgs e)
        {
            if (printerComboBox.SelectedItem != null) //判断是否有选中值
            {
                if (Externs.SetDefaultPrinter(printerComboBox.SelectedItem.ToString())) //设置默认打印机
                {
                    MessageBox.Show(printerComboBox.SelectedItem.ToString() + "设置为默认打印机成功！");
                }
                else
                {
                    MessageBox.Show(printerComboBox.SelectedItem.ToString() + "设置为默认打印机失败！");
                }
            }
        }

        private void simpleButton29_Click(object sender, EventArgs e)
        {
            String 绝对路径 = FileUtil.getAbsolutePath(@"tag\" + "PrintConfig.txt");
            String xx = System.IO.File.ReadAllText(绝对路径);
            DealXML.ObjectToXMLFile(new PrintMachineDTO("01", "测试打印机"), @"tag\" + "PrintConfig_003.txt", Encoding.UTF8);
            PrintMachineDTO printMachineDTO = DealXML.XMLFlieToObject<PrintMachineDTO>(FileUtil.getAbsolutePath(@"tag\" + "PrintConfig_003.txt"), Encoding.UTF8);

            DealXML.ObjectToXMLFile(new PrintMachineDTO("01", "测试打印机"), "D:\\ATEST\\fragment_smart\\DXApplicationTangche\\DXApplicationTangche\\bin\\Debug\\tag\\PrintConfig_003.txt", Encoding.UTF8);

            String 文件内容 = FileUtil.ReadFile(绝对路径, ".txt");

            String fileName = @"tag\" + "PrintConfig.txt";
            String text = "打印机名称变更";
            System.IO.File.WriteAllText(fileName, text);
            MessageBox.Show("完成");
        }

        private void simpleButton30_Click(object sender, EventArgs e)
        {
            String filePath1 = @"Resources\" + "SSHIRT.jpg";
            String filePath3 = @"..\..\" + "SSHIRT.jpg";
            String filePath4 = @"..\" + "SSHIRT.jpg";
            String filePath5 = "\\Resources\\SSHIRT.jpg";


            String filePath2 = "D:\\ATEST\\fragment_smart\\DXApplicationTangche\\DXApplicationTangche\\Resources\\" + "SSHIRT.jpg";
            bool xx1 = FileUtil.FileExist(filePath5);

            List<KashiyamaWipDTO> kashiyamaWipDTOs = 面料审核Service.getKashiyamaWipByPlanId("68363025b7264e7dbb4933b2ca75a82f");
            DataTable dt = DataUtil.ToDataTable<KashiyamaWipDTO>(kashiyamaWipDTOs);
            String fileName = @"tag\" + "坚山订单回执.xlsx";
            //String filePath = @"Resources\" + "坚山订单回执.xlsx";
            String filePath = @"doc\" + "坚山订单回执.xlsx";
            bool xx = FileUtil.FileExist(filePath);
            List<String> columns = new List<String>();
            columns.Add("orderNo");
            columns.Add("customerName");
            columns.Add("styleNameCn");
            columns.Add("materialCode");
            columns.Add("styleSizeCd");
            columns.Add("batchStatus");
            columns.Add("kashiyamaCreateDate");
            columns.Add("productNo");
            columns.Add("oyaProductNo");
            ExcelUtil.ToExcelTemplate(dt,fileName, filePath, 3, 1, columns);
        }

        private void simpleButton31_Click(object sender, EventArgs e)
        {
            byte[] buffer = Properties.Resources.抖音出库单;//获取嵌入dll文件的字节数组  
            string strPath = Application.StartupPath + @"\tag\" + "抖音出库单.xlsx";//设置释放路径   导出路径
                                                                                   //创建dll文件（覆盖模式）  
            using (FileStream fs = new FileStream(strPath, FileMode.Create))
            {
                fs.Write(buffer, 0, buffer.Length);
            }

        }

        private void simpleButton32_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.Filter = "csv|*.csv";
            ofd.Title = "请选择csv文件";
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                //List<String> dt = FileUtil.readCsvTxtToList(Path.GetFullPath(ofd.FileName));
                //List<String> csv解析结果 = new List<string>();
                //for (int i = 1; i < dt.Count(); i++)
                //{
                //    csv解析结果.Add(dt[i]);
                //}
                面料审核Service.saveDouyinOrder("SSHIRT", "11", ofd.FileName);
                
                MessageBox.Show("csv上传成功");
            }
        }
        public DataTable READExcel(string path)
        {
            Microsoft.Office.Interop.Excel.Application objXL = null;
            Microsoft.Office.Interop.Excel.Workbook objWB = null;
            objXL = new Microsoft.Office.Interop.Excel.Application();
            objWB = objXL.Workbooks.Open(path);
            Microsoft.Office.Interop.Excel.Worksheet objSHT = objWB.Worksheets[1];

            int rows = objSHT.UsedRange.Rows.Count;
            int cols = objSHT.UsedRange.Columns.Count;
            DataTable dt = new DataTable();
            int noofrow = 1;

            for (int c = 1; c <= cols; c++)
            {
                string colname = objSHT.Cells[1, c].Text;
                dt.Columns.Add(colname);
                noofrow = 2;
            }

            for (int r = noofrow; r <= rows; r++)
            {
                DataRow dr = dt.NewRow();
                for (int c = 1; c <= cols; c++)
                {
                    dr[c - 1] = objSHT.Cells[r, c].Text;
                }

                dt.Rows.Add(dr);
            }

            objWB.Close();
            objXL.Quit();
            return dt;
        }
        private List<String> readCsvTxt(string strpath)
        {
            List<String> csv解析 = new List<string>();
            string strline;
            string[] aryline;
            System.IO.StreamReader mysr = new System.IO.StreamReader(strpath);
            String partFile = "";
            //
            while ((strline = mysr.ReadLine()) != null)
            {
                csv解析.Add(strline);
                //aryline = strline.Split(',');
                //if (!strline.EndsWith("\r\n"))
                //    //每行串的长度51
                //    if (aryline.Length == 51)
                //    {
                //        //  常规解析

                //    }
                //    else {
                //        //  补充
                //        csv解析.Add(partFile + strline);
                //        partFile = "";
                //    }
                //else
                //{
                //    //  换行符结尾
                //    partFile = strline;
                //}
                //if (blnFlag)
                //{
                //    blnFlag = false;
                //    intColCount = aryline.Length;
                //    for (int i = 0; i < aryline.Length; i++)
                //    {
                //        mydc = new DataColumn(aryline[i]);
                //        mydt.Columns.Add(mydc);
                //    }
                //}
                //mydr = mydt.NewRow();
                //for (int i = 0; i < intColCount; i++)
                //{
                //    mydr[i] = aryline[i];
                //}
                //mydt.Rows.Add(mydr);
            }
            return csv解析;
        }

        private void simpleButton33_Click(object sender, EventArgs e)
        {
            LogHelp.WriteLog("123");
        }

        private void simpleButton34_Click(object sender, EventArgs e)
        {
            Stopwatch stopWatch = new Stopwatch();
            stopWatch.Start();
            ExcelAndPath excelAndPath = ExcelUtil.getExcelDataAndPath("");
            if (excelAndPath == null)
            {
                return;
            }
            DataSet result = excelAndPath.DataSet;
            stopWatch.Stop();
            System.Diagnostics.Debug.WriteLine("导成Dataset用时" + stopWatch.ElapsedMilliseconds + "ms");
            stopWatch.Start();
            if (result == null)
            {
                return;
            }
            DataTable dataTable = result.Tables[0];
            //获取数据
            List<DouyinOrderReturnDTO> douyinOrderReturnDTOs = new List<DouyinOrderReturnDTO>();
            for (int i = 1; i < dataTable.Rows.Count; i++)
            {
                try
                {
                    if (String.IsNullOrEmpty(dataTable.Rows[i]["Column0"].ToString()))
                    {
                        break;
                    }
                }
                catch (Exception)
                {
                    break;
                }
                #region

                #endregion
                douyinOrderReturnDTOs.Add(
                    new DouyinOrderReturnDTO(
                     dataTable.Rows[i]["Column0"].ToString(),    //售后单号
                     dataTable.Rows[i]["Column1"].ToString(),  //订单号
                     dataTable.Rows[i]["Column2"].ToString(),  //商品单号
                     dataTable.Rows[i]["Column3"].ToString(), //商品名称
                     dataTable.Rows[i]["Column4"].ToString(),   //商品ID
                     dataTable.Rows[i]["Column5"].ToString(), //应付金额（元）
                     dataTable.Rows[i]["Column6"].ToString(),   //商品运费（元）
                     dataTable.Rows[i]["Column7"].ToString(),//支付优惠（元）
                     dataTable.Rows[i]["Column8"].ToString(),   //商品税费（元）
                     dataTable.Rows[i]["Column9"].ToString(),  //商品发货状态
                     dataTable.Rows[i]["Column10"].ToString(),   //售后类型
                     dataTable.Rows[i]["Column11"].ToString(), //退商品金额（元）
                     dataTable.Rows[i]["Column12"].ToString(), //退运费金额（元）
                     dataTable.Rows[i]["Column13"].ToString(), //退支付优惠（元）
                     dataTable.Rows[i]["Column14"].ToString(),   //退税费金额（元）
                     dataTable.Rows[i]["Column15"].ToString(), //售后状态
                     dataTable.Rows[i]["Column16"].ToString(),    //售后申请时间
                     dataTable.Rows[i]["Column17"].ToString(),  //退款方式
                     dataTable.Rows[i]["Column18"].ToString(),  //是否已上传退款凭证
                     dataTable.Rows[i]["Column19"].ToString(), //售后原因
                     dataTable.Rows[i]["Column20"].ToString(),  //退货物流单号
                     dataTable.Rows[i]["Column21"].ToString(), //退货异常
                     dataTable.Rows[i]["Column22"].ToString(), //退货发货时间
                     dataTable.Rows[i]["Column23"].ToString(),  //退货物流公司
                     dataTable.Rows[i]["Column24"].ToString(),    //自动处理截止时间
                     dataTable.Rows[i]["Column25"].ToString(),  //同意售后申请时间
                     dataTable.Rows[i]["Column26"].ToString(),    //退款成功时间
                     dataTable.Rows[i]["Column27"].ToString(),    //售后关闭时间
                     dataTable.Rows[i]["Column28"].ToString(),  //商家退货地址
                     dataTable.Rows[i]["Column29"].ToString(),    //商家退货联系人姓名
                     dataTable.Rows[i]["Column30"].ToString(),  //商家退货联系人电话
                     dataTable.Rows[i]["Column31"].ToString(),  //客服仲裁
                     dataTable.Rows[i]["Column32"].ToString(),  //纠纷责任方
                     dataTable.Rows[i]["Column33"].ToString(),    //是否极速退款
                     dataTable.Rows[i]["Column34"].ToString(), //正向物流状态
                     dataTable.Rows[i]["Column35"].ToString()   //是否拒签后退款
                    )    
                );

            }
            抖音订单Service.saveDouyinOrderReturn(douyinOrderReturnDTOs);
            MessageBox.Show("导入完成");
        }

        private void simpleButton35_Click(object sender, EventArgs e)
        {
            List<FPAYBILLENTRYItem> fPAYBILLENTRYItems = new List<FPAYBILLENTRYItem>();
            fPAYBILLENTRYItems.Add(new FPAYBILLENTRYItem("JSFS02_SYS", "SFKYT12_SYS", 150, "411907698210333"));
            //查询
            // 使用webapi引用组件Kingdee.BOS.WebApi.Client.dll
            K3CloudApiClient client = new K3CloudApiClient("http://192.168.3.251/k3cloud/");
            var loginResult = client.ValidateLogin("6128407938e2f2", "Administrator", "Sshirt@1234", 2052);
            var resultType = JObject.Parse(loginResult)["LoginResultType"].Value<int>();
            //登录结果类型等于1，代表登录成功
            if (resultType == 1)
            {
                //String result = client.View("AR_RECEIVEBILL", "{\"Number\":\"SKD00000001\",\"Id\":\"100001\"}");
                //String result = client.View("AP_PAYBILL", "{\"Number\":\"FKD00000013\",\"Id\":\"100014\"}");
                //SKDLX01_SYS
                //String result = client.Save("AR_RECEIVEBILL", FunctionHelper.JsonSerialization(new PayBillRoot("FKDLX02_SYS", "BD_Department", "BM000001", "BD_Department", "BM000001", fPAYBILLENTRYItems)));
                String result = client.Save("AR_RECEIVEBILL", FunctionHelper.JsonSerialization(new PayBillRoot("SKDLX01_SYS", "BD_Department", "BM000001", "BD_Department", "BM000001", fPAYBILLENTRYItems)));
                KingDeeAddResultRoot materialResultRoot = FunctionHelper.JsonDeserialization<KingDeeAddResultRoot>(result);
                String Submitresult = client.Submit("AP_PAYBILL", FunctionHelper.JsonSerialization(new dto.MaterialSubmitDTO(materialResultRoot.Result.Number, materialResultRoot.Result.Id.ToString())));
                String SupplierVerifyresult = client.Audit("AP_PAYBILL", FunctionHelper.JsonSerialization(new dto.MaterialVerifyDTO(materialResultRoot.Result.Number, materialResultRoot.Result.Id.ToString())));
            }
        }
        /// <summary>
        /// 收款
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void simpleButton36_Click(object sender, EventArgs e)
        {
            //DouyinFinancialQueryFacadeDTO douyinFinancialQueryFacadeDTO = new DouyinFinancialQueryFacadeDTO();
            //List<DouyinFinancialSimpleDTO> douyinFinancialSimpleDTOs = new List<DouyinFinancialSimpleDTO>();
            //douyinFinancialSimpleDTOs = douyinFinancialQueryFacadeDTO.douyinFinancialSimpleDTOS;
            //String FDATE = douyinFinancialSimpleDTOs[0].dateStr;
            //分录
            List<FRECEIVEBILLENTRYItem> fRECEIVEBILLENTRYItems = new List<FRECEIVEBILLENTRYItem>();
            fRECEIVEBILLENTRYItems.Add(new FRECEIVEBILLENTRYItem("JSFS04_SYS", "SFKYT002", 150, "411907698210333"));
            //foreach(DouyinFinancialSimpleDTO douyinFinancialSimpleDTO in douyinFinancialSimpleDTOs)
            //{
            //    double payCount = douyinFinancialSimpleDTO.payable;
            //    fRECEIVEBILLENTRYItems.Add(new FRECEIVEBILLENTRYItem("JSFS04_SYS", "SFKYT002", payCount, "411907698210333"));
            //}
            K3CloudApiClient client = new K3CloudApiClient("http://192.168.3.251/k3cloud/");
            var loginResult = client.ValidateLogin("6128407938e2f2", "Administrator", "Sshirt@1234", 2052);
            var resultType = JObject.Parse(loginResult)["LoginResultType"].Value<int>();
            //登录结果类型等于1，代表登录成功
            if (resultType == 1)
            {
                //String result = client.View("AR_RECEIVEBILL", "{\"Number\":\"SKD00000010\",\"Id\":\"100010\"}");
                String result = client.Save("AR_RECEIVEBILL", FunctionHelper.JsonSerialization(new ReceieveBilRoot("SKDLX01_SYS", "BD_Customer", "CUST0004", "BD_Customer", "CUST0004", "2021-12-25", fRECEIVEBILLENTRYItems)));
                KingDeeAddResultRoot materialResultRoot = FunctionHelper.JsonDeserialization<KingDeeAddResultRoot>(result);
                String Submitresult = client.Submit("AR_RECEIVEBILL", FunctionHelper.JsonSerialization(new dto.MaterialSubmitDTO(materialResultRoot.Result.Number, materialResultRoot.Result.Id.ToString())));
                String SupplierVerifyresult = client.Audit("AR_RECEIVEBILL", FunctionHelper.JsonSerialization(new dto.MaterialVerifyDTO(materialResultRoot.Result.Number, materialResultRoot.Result.Id.ToString())));
            }
        }
        /// <summary>
        /// 退款
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void simpleButton37_Click(object sender, EventArgs e)
        {
            List<FREFUNDBILLENTRYItem> fREFUNDBILLENTRYItems = new List<FREFUNDBILLENTRYItem>();
            fREFUNDBILLENTRYItems.Add(new FREFUNDBILLENTRYItem("JSFS04_SYS", "SFKYT002", 350, "411907698210333"));
            K3CloudApiClient client = new K3CloudApiClient("http://192.168.3.251/k3cloud/");
            var loginResult = client.ValidateLogin("6128407938e2f2", "Administrator", "Sshirt@1234", 2052);
            var resultType = JObject.Parse(loginResult)["LoginResultType"].Value<int>();
            //登录结果类型等于1，代表登录成功
            if (resultType == 1)
            {
                //SKTKDLX01_SYS    CUST0002     BD_Customer
                //String result = client.View("AR_REFUNDBILL", "{\"Number\":\"SKTKD00000001\",\"Id\":\"100001\"}");
                String result = client.Save("AR_REFUNDBILL", FunctionHelper.JsonSerialization(new RefoundBillRoot("SKTKDLX01_SYS", "BD_Customer", "CUST0004", "BD_Customer", "CUST0004","2021-12-25", fREFUNDBILLENTRYItems)));
                KingDeeAddResultRoot materialResultRoot = FunctionHelper.JsonDeserialization<KingDeeAddResultRoot>(result);
                String Submitresult = client.Submit("AR_REFUNDBILL", FunctionHelper.JsonSerialization(new dto.MaterialSubmitDTO(materialResultRoot.Result.Number, materialResultRoot.Result.Id.ToString())));
                String SupplierVerifyresult = client.Audit("AR_REFUNDBILL", FunctionHelper.JsonSerialization(new dto.MaterialVerifyDTO(materialResultRoot.Result.Number, materialResultRoot.Result.Id.ToString())));
            }
        }

        private void simpleButton38_Click(object sender, EventArgs e)
        {

        }
    }
    public class LocalPrinter
    {
        private static PrintDocument fPrintDocument = new PrintDocument();
        //获取本机默认打印机名称
        public static String DefaultPrinter()
        {
            return fPrintDocument.PrinterSettings.PrinterName;
        }
        public static List<String> GetLocalPrinters()
        {
            List<String> fPrinters = new List<String>();
            fPrinters.Add(DefaultPrinter()); //默认打印机始终出现在列表的第一项
            foreach (String fPrinterName in PrinterSettings.InstalledPrinters)
            {
                if (!fPrinters.Contains(fPrinterName))
                {
                    fPrinters.Add(fPrinterName);
                }
            }
            return fPrinters;
        }
    }
    public class Externs
    {
        [DllImport("winspool.drv")]
        public static extern bool SetDefaultPrinter(String Name); //调用win api将指定名称的打印机设置为默认打印机
    }
    public class OrderDetailDTO
    {
        public String orderNo { get; set; }
        public String customerName { get; set; }
        public String styleNameCn { get; set; }
        public String materialCode { get; set; }
        public String styleSizeCd { get; set; }
        public String orderNumber { get; set; }
        public String orderDate { get; set; }
        public String businessType { get; set; }
        public String fnumber { get; set; }


        public OrderDetailDTO()
        {

        }

        public OrderDetailDTO(string orderNo, string customerName, string styleNameCn, string materialCode, string styleSizeCd, string orderNumber, string orderDate, string businessType,String fnumber)
        {
            this.orderNo = orderNo;
            this.customerName = customerName;
            this.styleNameCn = styleNameCn;
            this.materialCode = materialCode;
            this.styleSizeCd = styleSizeCd;
            this.orderNumber = orderNumber;
            this.orderDate = orderDate;
            this.businessType = businessType;
            this.fnumber = fnumber;
        }
    }
    class MaterialImportDTO
    {
        public String materialNo { get; set; }
        public String meterialDesc { get; set; }
        public String fSupplierNumber { get; set; }
        public int group { get; set; }
        public MaterialImportDTO()
        {

        }

        public MaterialImportDTO(string materialNo, string meterialDesc, string fSupplierNumber, int group)
        {
            this.materialNo = materialNo;
            this.meterialDesc = meterialDesc;
            this.fSupplierNumber = fSupplierNumber;
            this.group = group;
        }
    }
}
